const Koa = require('koa')

const app = new Koa()

console.log(app, 'app')
// logger
app.use(async (ctx, next) => {
  await next()
  const rt = ctx.response.get('X-Response-Time')
  console.log(`${ctx.method} ${ctx.url} -  ${rt}`)
})

// X-Response-Time
app.use(async (ctx, next) => {
  const start = Date.now()
  await next()
  const ms = Date.now() - start
  ctx.set('X-Response-Time', `${ms}ms`)
  console.log(`ms-${ms}`)
})

app.use(async (ctx, next) => {
  console.log(ctx.req)
  await 
})

app.use(async ctx => {
  ctx.body = 'Koa --!!'
})

app.on('error', (err, ctx) => {
  console.log(err, 'err')
})

app.listen(3000)
